home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_dbm.h.z / apr_dbm.h
C/C++ Source or Header  |  2002-07-08  |  11KB  |  272 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_DBM_H
  56. #define APR_DBM_H
  57.  
  58. #include "apu.h"
  59. #include "apr.h"
  60. #include "apr_errno.h"
  61. #include "apr_pools.h"
  62. #include "apr_file_info.h"
  63.  
  64. #ifdef __cplusplus
  65. extern "C" {
  66. #endif
  67.  
  68. /**
  69.  * @file apr_dbm.h
  70.  * @brief APR-UTIL DBM library
  71.  */
  72. /** 
  73.  * @defgroup APR_Util_DBM DBM routines
  74.  * @ingroup APR_Util
  75.  * @{
  76.  */
  77. /**
  78.  * Structure for referencing a dbm
  79.  */
  80. typedef struct apr_dbm_t apr_dbm_t;
  81.  
  82. /**
  83.  * Structure for referencing the datum record within a dbm
  84.  */
  85. typedef struct
  86. {
  87.     /** pointer to the 'data' to retrieve/store in the DBM */
  88.     char *dptr;
  89.     /** size of the 'data' to retreive/store in the DBM */
  90.     apr_size_t dsize;
  91. } apr_datum_t;
  92.  
  93. /* modes to open the DB */
  94. #define APR_DBM_READONLY        1       /**< open for read-only access */
  95. #define APR_DBM_READWRITE       2       /**< open for read-write access */
  96. #define APR_DBM_RWCREATE        3       /**< open for r/w, create if needed */
  97. #define APR_DBM_RWTRUNC         4       /**< open for r/w, truncating a existing
  98.                                           DB if present */
  99. /**
  100.  * Open a dbm file by file name and type of DBM
  101.  * @param dbm The newly opened database
  102.  * @param type The type of the DBM (not all may be available at run time)
  103.  * <pre>
  104.  *  GDBM for GDBM files
  105.  *  SDBM for SDBM files
  106.  *  DB   for berkeley DB files
  107.  *  default for the default DBM type
  108.  *  </pre>
  109.  * @param name The dbm file name to open
  110.  * @param mode The flag value
  111.  * <PRE>
  112.  *           APR_DBM_READONLY   open for read-only access
  113.  *           APR_DBM_READWRITE  open for read-write access
  114.  *           APR_DBM_RWCREATE   open for r/w, create if needed
  115.  *           APR_DBM_RWTRUNC    open for r/w, truncatate if already there
  116.  * </PRE>
  117.  * @param perm Permissions to apply to if created
  118.  * @param cntxt The pool to use when creating the dbm
  119.  * @deffunc apr_status_t apr_dbm_open(apr_dbm_t **dbm, const char *name, int mode
  120.  * @tip The dbm name may not be a true file name, as many dbm packages
  121.  * append suffixes for seperate data and index files.
  122.  */
  123.  
  124. APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **dbm, const char* type, 
  125.                                        const char *name, 
  126.                                        apr_int32_t mode, apr_fileperms_t perm,
  127.                                        apr_pool_t *cntxt);
  128.  
  129.  
  130. /**
  131.  * Open a dbm file by file name
  132.  * @param dbm The newly opened database
  133.  * @param name The dbm file name to open
  134.  * @param mode The flag value
  135.  * <PRE>
  136.  *           APR_DBM_READONLY   open for read-only access
  137.  *           APR_DBM_READWRITE  open for read-write access
  138.  *           APR_DBM_RWCREATE   open for r/w, create if needed
  139.  *           APR_DBM_RWTRUNC    open for r/w, truncatate if already there
  140.  * </PRE>
  141.  * @param perm Permissions to apply to if created
  142.  * @param cntxt The pool to use when creating the dbm
  143.  * @deffunc apr_status_t apr_dbm_open(apr_dbm_t **dbm, const char *name, int mode
  144.  * @tip The dbm name may not be a true file name, as many dbm packages
  145.  * append suffixes for seperate data and index files.
  146.  */
  147. APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **dbm, const char *name, 
  148.                                        apr_int32_t mode, apr_fileperms_t perm,
  149.                                        apr_pool_t *cntxt);
  150.  
  151. /**
  152.  * Close a dbm file previously opened by apr_dbm_open
  153.  * @param dbm The database to close
  154.  * @deffunc void apr_dbm_close(apr_dbm_t *dbm)
  155.  */
  156. APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm);
  157.  
  158. /**
  159.  * Fetch a dbm record value by key
  160.  * @param dbm The database 
  161.  * @param key The key datum to find this record
  162.  * @param value The value datum retrieved for this record
  163.  * @deffunc apr_status_t apr_dbm_fetch(apr_dbm_t *dbm, apr_datum_t key
  164.  */
  165. APU_DECLARE(apr_status_t) apr_dbm_fetch(apr_dbm_t *dbm, apr_datum_t key,
  166.                                         apr_datum_t *pvalue);
  167. /**
  168.  * Store a dbm record value by key
  169.  * @param dbm The database 
  170.  * @param key The key datum to store this record by
  171.  * @param value The value datum to store in this record
  172.  * @deffunc apr_status_t apr_dbm_store(apr_dbm_t *dbm, apr_datum_t key, apr_datum_t value)
  173.  */
  174. APU_DECLARE(apr_status_t) apr_dbm_store(apr_dbm_t *dbm, apr_datum_t key, 
  175.                                         apr_datum_t value);
  176.  
  177. /**
  178.  * Delete a dbm record value by key
  179.  * @param dbm The database 
  180.  * @param key The key datum of the record to delete
  181.  * @deffunc apr_status_t apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key)
  182.  * @tip It is not an error to delete a non-existent record.
  183.  */
  184. APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key);
  185.  
  186. /**
  187.  * Search for a key within the dbm
  188.  * @param dbm The database 
  189.  * @param key The datum describing a key to test
  190.  * @deffunc int apr_dbm_exists(apr_dbm_t *dbm, apr_datum_t key)
  191.  */
  192. APU_DECLARE(int) apr_dbm_exists(apr_dbm_t *dbm, apr_datum_t key);
  193.  
  194. /**
  195.  * Retrieve the first record key from a dbm
  196.  * @param dbm The database 
  197.  * @param key The key datum of the first record
  198.  * @deffunc apr_status_t apr_dbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey)
  199.  */
  200. APU_DECLARE(apr_status_t) apr_dbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey);
  201.  
  202. /**
  203.  * Retrieve the next record key from a dbm
  204.  * @param dbm The database 
  205.  * @param key The key datum of the next record
  206.  * @deffunc apr_status_t apr_dbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey)
  207.  */
  208. APU_DECLARE(apr_status_t) apr_dbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey);
  209.  
  210. /**
  211.  * Proactively toss any memory associated with the apr_datum_t.
  212.  * @param dbm The database 
  213.  * @param data The datum to free.
  214.  * @deffunc void apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data)
  215.  */
  216. APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data);
  217.  
  218. /**
  219.  * Report more information when an apr_dbm function fails.
  220.  * @param dbm The database
  221.  * @param errcode A DBM-specific value for the error (for logging). If this
  222.  *                isn't needed, it may be NULL.
  223.  * @param errbuf Location to store the error text
  224.  * @param errbufsize The size of the provided buffer
  225.  * @return The errbuf parameter, for convenience.
  226.  * @deffunc const char * apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, char *errbuf, apr_size_t errbufsize)
  227.  */
  228. APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode,
  229.                                      char *errbuf, apr_size_t errbufsize);
  230. /**
  231.  * If the specified file/path were passed to apr_dbm_open(), return the
  232.  * actual file/path names which would be (created and) used. At most, two
  233.  * files may be used; used2 may be NULL if only one file is used.
  234.  * @param pool The pool for allocating used1 and used2.
  235.  * @param type The type of DBM you require info on
  236.  * @param pathname The path name to generate used-names from.
  237.  * @param used1 The first pathname used by the apr_dbm implementation.
  238.  * @param used2 The second pathname used by apr_dbm. If only one file is
  239.  *              used by the specific implementation, this will be set to NULL.
  240.  * @tip The dbm file(s) don't need to exist. This function only manipulates
  241.  *      the pathnames.
  242.  */
  243. APU_DECLARE(void) apr_dbm_get_usednames_ex(apr_pool_t *pool,
  244.                                         const char *type,
  245.                                         const char *pathname,
  246.                                         const char **used1,
  247.                                         const char **used2);
  248.  
  249. /**
  250.  * If the specified file/path were passed to apr_dbm_open(), return the
  251.  * actual file/path names which would be (created and) used. At most, two
  252.  * files may be used; used2 may be NULL if only one file is used.
  253.  * @param pool The pool for allocating used1 and used2.
  254.  * @param pathname The path name to generate used-names from.
  255.  * @param used1 The first pathname used by the apr_dbm implementation.
  256.  * @param used2 The second pathname used by apr_dbm. If only one file is
  257.  *              used by the specific implementation, this will be set to NULL.
  258.  * @tip The dbm file(s) don't need to exist. This function only manipulates
  259.  *      the pathnames.
  260.  */
  261. APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *pool,
  262.                                         const char *pathname,
  263.                                         const char **used1,
  264.                                         const char **used2);
  265.  
  266. /** @} */
  267. #ifdef __cplusplus
  268. }
  269. #endif
  270.  
  271. #endif    /* !APR_DBM_H */
  272.